{extend name="public/base" /}

{block name="title"}{$systems.webname}{/block}

{block name="main"}
<div class="content center-block animated fadeInDown">
    <div class="page-header h1">用户登录</div>
    <form>
        <div class="form-group">
            <label for="username" class="control-label">用户名</label>
            <input type="text" class="form-control" id="username" name="username" placeholder="用户名"/>
        </div>
        <div class="form-group">
            <label for="password" class="control-label">密码</label>
            <input type="password" class="form-control" id="password" name="password" placeholder="密码"/>
        </div>
        <div class="form-group">
            <label for="verify" class="control-label">验证码</label>
            <div class="input-group">
                <input type="text" class="form-control" id="verify" name="verify" placeholder="验证码"/>
                <span class="input-group-addon">123</span>
            </div>
        </div>
        <div class="form-group">
            <button type="submit" id="smt" class="btn btn-primary btn-block">登录</button>
        </div>
    </form>
</div>
{/block}
{block name="js"}
<script>
    $(function () {
        $("#smt").on('click', function () {
            console.log(`登陆`);
            $.ajax({
                url: "{:url('index/index/login')}",
                type: "post",
                data: $("form").serialize(),
                dataType: "json",
                success: function (data) {
                    console.log(data);
                        if (data.code == 1) {
                            layer.msg("登陆成功", {
                                icon: 6,
                                time: 2000
                            }, function () {
                                location.href = data.url
                            })
                        } else {
                            layer.open({
                                title: "操作失败",
                                content: data.msg,
                                icon: 5
                            });
                        }
                }
            });
            return false;
        });
    })
</script>
{/block}